﻿<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta http-equiv="Pragma" content="no-cache">
		<meta http-equiv="Cache-Control" content="no-cache">
		<meta http-equiv="Expires" content="0">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
		<title>网站后台管理系统</title>
		<link href="/apps/admin/login.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="/apps/admin/view/default/layui/css/layui.css">
	</head>
	<body>
		<div class="login_box">
			  <div class="login_l_img"><img src="/apps/admin/login-img.png" /></div>
			  <div class="login">
					<div class="login_logo"><a href="#"><img src="/apps/admin/login_logo.png" /></a></div>
					<div class="login_name">
						<p>后台管理系统</p>
					</div>
					<form action="{url./admin/Index/login}" method="post" class="layui-form" id="dologin">
						<input type="hidden" name="formcheck" id="formcheck" value="{$formcheck}" >
						<input name="username" type="text" placeholder="用户名" required=required>
						<input name="password" type="password" placeholder="密码" required=required>

						{if([$admin_check_code])}
						<div class="afe4189fwa4">
							<div class="erg8748er">
								<input name="checkcode" type="text" placeholder="验证码" required=required>
							</div>
							<div class="yj784nh1yrft">
								<img title="点击刷新"  src="{CORE_DIR}/code.php" class="chicuele" id="imgVerify" alt="" onclick="fleshVerify();" >
							</div>
						</div>
						{/if}

						<input value="登录" style="width:100%;" type="submit">
					</form>

		  	  </div>
		</div>
		<script type="text/javascript" src="{APP_THEME_DIR}/js/jquery-1.12.4.min.js"></script>
		<script type="text/javascript" src="/apps/admin/view/default/layui/layui.all.js"></script>
		<script>
		$(function(){
			$('#dologin').submit(function(){
				$.ajax({
					type: 'POST',
					url: $(this).attr('action'),
					dataType: 'json',
					data: $(this).serialize(),
					success: function (response, status) {
						if (response.code == 1) {
							layer.msg("登录成功！", {icon: 1});
							window.location.href = response.data;
						} else {
							fleshVerify();
							layer.msg("登录失败：" + response.data, {icon: 5});
						}
					},
					error:function(xhr,status,error){
						layer.msg("请求发生错误!", {icon: 5});
					}
				});
				return false;
			});
		});
		function fleshVerify(){
			var src = "{CORE_DIR}/code.php";
			if (src.indexOf('?') > -1) {
				src += '&';
			} else {
				src += '?';
			}
			src += 'r='+Math.floor(Math.random()*100);
			$('#imgVerify').attr('src', src);//重载验证码
		}

		</script>
	</body>
</html>
